package edu.office.applicationRepository;

import edu.office.entities.Statusofresources;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Named;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author hgs
 */
@Named("statusofresourcesRepositoryA")
@ApplicationScoped
public class StatusofresourcesRepository extends ApplicationCommonRepository<Statusofresources>{

    List<Statusofresources> statusofresourceseList=new LinkedList<>();

    public List<Statusofresources> getStatusofresourceList() {
        if ( statusofresourceseList.isEmpty()) {
            statusofresourceseList = listAll();
        }
        return statusofresourceseList;
    }

    public Statusofresources getStatusofresources(String name) {
        for (Statusofresources sf : getStatusofresourceList()) {
            if(sf.getMEANING().equals(name)){
                return sf;
            }
        }
        return null;
    }

    public Statusofresources getReexaming(){
        return getStatus(0);
    }
    public Statusofresources getPassed(){
        return getStatus(1);
    }
    
      public Statusofresources getPassedFaild(){
        return getStatus(2);
    }
      public Statusofresources getSaved(){
          return getStatus(3);
      }
      
      private  Statusofresources getStatus(int id){
        Statusofresources result=null;
        for(Statusofresources statusofresource:getStatusofresourceList()) {
            if(statusofresource.getID()==id){
                result=statusofresource;
                break;
            }
        }
        return result;
    }
}
